#include <random>
#include <iostream>
#include "pub_defs.h"

int main(int argc, char* argv[]) {
    if (argc!=3){
        std::cerr<<"usage ./optimized M N" <<std::endl;
        return 1;
    }
    int m = std::atoi(argv[1]);
    int n = std::atoi(argv[2]);

    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(0,1);
    uint8_t* arr = new uint8_t[(m+2)*(n+2)];
    for (int i = 1; i < m+1; i++) {
        for (int j = 1; j < n+1; j++) {
            arr[i*(n+2) + j] = dis(gen);
        }
    }
    // debug print
    write_binfile(arr, (m+2)*(n+2), "input.bin");
    double start_time = wall_time();
    gameoflife_baseline(arr, m, n);
    double last_time = wall_time()-start_time;
    std::cout <<"M:"<<m<<" n: "<<n << " gen data baseline Time elapsed: " << last_time << " seconds." << std::endl;
    write_binfile(arr, (m+2)*(n+2), "output.bin");

    return 0;
}